<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
    $(function() {
       $( "#datepicker" ).datepicker();
    });
</script>
<div class="content">       
        <div class="content_header">
        <?php 
        $editable = '<script type="text/javascript" src="'.base_url().'js/jquery.editable-1.7.js"></script>';
        echo "<span style='text-transform:uppercase'>".$phongban->ten_lich."</span>";
        if($checkQuyen)
        	echo $editable;       
        ?>        

        <!-- <input type="button" value="Xuất ra excel" onClick="window.location='<?php //echo site_url('lichlamviec/exportExcel/'.$excel);?>'"/> --> 
        <input type="text" name="ngaychuyen" value="" title="Đinh dạng dd/mm/YYYY" id="datepicker"/>          
        <input type="button" value="Chuyển đến ngày" onClick="rederictUrl('<?php echo $phongban->id_danhsachlich?>')"/>      
        </div>
        <div class="content_table">
            <table>
                <tr>
                	<th>&nbsp;&nbsp;&nbsp;</th>
                    <th>TG</th>
                <?php 
                foreach ($thu2_chunhat as $thu=>$ngay){
              	?>             
              		<?php list($year, $month, $day) = explode("-",$ngay);?>              
                    <th><?php echo $thu."<br/><span style='font-size:10px'>(".$day."-".$month."-".$year.")</span>";?></th>
                            
                <?php }
                ?>
                </tr>
                <?php  
                $count = 2;
                $i=1;
                foreach ($users as $row_user){ 
					if($count%2==0)				
						$style="class='row_type_1'";     
					else
						$style=""; 
					$count++;                           	                               
                ?>                
                <tr <?php echo $style?>>
                    <td class="group_cell_1"></td>
                    <td>Sáng</td>
                    <?php                                        
                    foreach($thu2_chunhat as $key=>$value){                    	                   
                    ?>                      
                    <td align="left" valign="top">                    
                    <script> 
                    $(function(){
	                     id_nguoidung = '<?php echo $row_user->id_nguoidung?>';
		                 thoidiem = '1';	//sang
		                 ngay = '<?php echo $value?>';	                 		                
		                 id_lich = '<?php echo isset($lichlamviec[$row_user->id_nguoidung][$value][1]["id"])?$lichlamviec[$row_user->id_nguoidung][$value][1]["id"]:"";?>';                                     
	                    $('#s<?php echo $row_user->id_nguoidung.$i."1"; ?>').editable('<?php echo site_url("lichlamviec/them_lich")?>',{
	                        type:'textarea', 
	                        rows:10,                                                                                              
	                        submit:'Lưu',                         
	                        cancel:'Thoát',
	                        name: '_noidung',
	                        placeholder: '-',
	                        loadtype: 'POST',	                        
	                        cssclass : 'form_lich',
	                        submitdata:{_userid:id_nguoidung, _thoidiem:thoidiem, _date:ngay, _id:id_lich},
	                        callback:function(value,settings){		                        
								//alert(value);
	                    	} ,
	                    	data: function(value,settings){
	                    		/* Convert <br> to newline. */
	                    	      var retval = value.replace(/<br[\s\/]?>/gi, '');
	                    	      return retval;
	                    	}                    		                                                                 
	                    });	                
                    })                    
                    </script>
                    	<div class="editable" title="Click to edit" id="s<?php echo $row_user->id_nguoidung.$i."1"; ?>">
                    	<?php
                    	echo isset($lichlamviec[$row_user->id_nguoidung][$value][1]["noidung"])?$lichlamviec[$row_user->id_nguoidung][$value][1]["noidung"]:"" 
                    	?>  
                    	</div>
                    	                  	
                    </td>
                    <?php                     		
                    $i++;
                    }
                   	?>                  
                </tr>
                <tr <?php echo $style?>>
                    <td class="group_cell_2"><b><?php echo $row_user->tenthat_nguoidung;?></b></td>
                    <td>Chiều</td>
                    <?php                                        
                    foreach($thu2_chunhat as $key=>$value){                    	                    
                    ?>
                    <td align="left" valign="top">
                    <script>  
                    $(function(){ 
                        id_nguoidung = '<?php echo $row_user->id_nguoidung?>';
		                thoidiem = '2';	//chieu
		                ngay = '<?php echo $value?>';		                 		                
		                id_lich = '<?php echo isset($lichlamviec[$row_user->id_nguoidung][$value][2]["id"])?$lichlamviec[$row_user->id_nguoidung][$value][2]["id"]:"";?>';                                 
	                    $('#c<?php echo $row_user->id_nguoidung.$i."2"; ?>').editable('<?php echo site_url("lichlamviec/them_lich")?>',{
	                    	 	type:'textarea', 
		                        rows:10,                                                                                              
		                        submit:'Lưu',                         
		                        cancel:'Thoát',
		                        name: '_noidung',
		                        placeholder: '-',
		                        loadtype: 'POST',	                        
		                        cssclass : 'form_lich',
		                        submitdata:{_userid:id_nguoidung, _thoidiem:thoidiem, _date:ngay, _id:id_lich},
		                        callback:function(value,settings){
									//alert(value);
		                    	} ,
		                    	data: function(value,settings){
		                    		/* Convert <br> to newline. */
		                    	      var retval = value.replace(/<br[\s\/]?>/gi, '');
		                    	      return retval;
		                    	}   	                    	
	                 	});
                    })                  
                    </script>
	                    <div class="editable" title="Click to edit" id="c<?php echo $row_user->id_nguoidung.$i."2"; ?>">
	                    	<?php 
	                    	echo isset($lichlamviec[$row_user->id_nguoidung][$value][2]["noidung"])?$lichlamviec[$row_user->id_nguoidung][$value][2]["noidung"]:""; 
	                    	?>                    	
	                    </div>
                    </td>                   		
                   	<?php
                   	$i++; 
                    }                    
                    ?>
                </tr>
                <tr <?php echo $style?>>
                    <td class="group_cell_3"></td>
                    <td>Tối</td>
                     <?php                                        
                    foreach($thu2_chunhat as $key=>$value){                   	
                    ?>
                    <td align="left" valign="top">
                     <script>
                     $(function(){
                    	id_nguoidung = '<?php echo $row_user->id_nguoidung?>';
		                thoidiem = '3';
		                ngay = '<?php echo $value?>';		                		                
		                id_lich = '<?php echo isset($lichlamviec[$row_user->id_nguoidung][$value][3]["id"])?$lichlamviec[$row_user->id_nguoidung][$value][3]["id"]:"";?>';  
	                     $('#t<?php echo $row_user->id_nguoidung.$i."3"; ?>').editable('<?php echo site_url("lichlamviec/them_lich")?>',{
	                    	 type:'textarea', 
		                        rows:10,                                                                                              
		                        submit:'Lưu',                         
		                        cancel:'Thoát',
		                        name: '_noidung',
		                        placeholder: '-',
		                        loadtype: 'POST',	                        
		                        cssclass : 'form_lich',
		                        submitdata:{_userid:id_nguoidung, _thoidiem:thoidiem, _date:ngay, _id:id_lich},
		                        callback:function(value,settings){			                        
									//alert(value);
		                    	} ,
		                    	data: function(value,settings){
		                    		/* Convert <br> to newline. */
		                    	      var retval = value.replace(/<br[\s\/]?>/gi, '');
		                    	      return retval;
		                    	} 
		                 });            
	                 })
                    </script>
                    	<div class="editable" title="Click to edit" id="t<?php echo $row_user->id_nguoidung.$i."3"; ?>">
                    	<?php 
                    	echo isset($lichlamviec[$row_user->id_nguoidung][$value][3]["noidung"])?$lichlamviec[$row_user->id_nguoidung][$value][3]["noidung"]:"" 
                    	?>                    
                    	</div>
                    </td>                   		
                   	<?php
                   	$i++; 
                    }
                    ?>
                </tr>
                <?php 
                }
                ?>                
            </table>
            <div style="clear:both"></div>
        </div>
    </div>
</div>